<!--分享二维码弹层-->
<div id="showsharecode" class="modal fade" tabindex="-1" style="z-index:99999;display:none;">
<div class="modal-dialog" style="width:100%;left:0;bottom:0">
<div class="modal-bottom">
    <div ng-if="pagedata.commission_data.codeShare==1" class="alert-content">
        <div class="alert" style="padding:0;">
            <i class="alert-close alert-close1 icon icon-close"></i>
            <div class="fui-list alert-header" style="-webkit-border-radius: 0.3rem;border-radius: 0.3rem;padding:0;">
                <img ng-src="{{tomedia(pagedata.goodscode)}}" width="100%" height="100%" class="alert-goods-img" alt="">
            </div>
        </div>
    </div>

    <div ng-if="pagedata.commission_data.codeShare==2" class="alert-content">
        <div class="alert2">
            <div class="fui-list alert-header" style="-webkit-border-radius: 0.3rem;border-radius: 0.3rem;padding:0;">
                <img ng-src="{{tomedia(pagedata.goodscode)}}" width="100%" height="100%" class="alert-goods-img" alt="">
            </div>
        </div>
    </div>

    <div ng-if="pagedata.commission_data.codeShare!=1 && pagedata.commission_data.codeShare!=2" class="alert-content">
        <div class="alert" style="padding:0;background: #f5f4f9;border:none;-webkit-border-radius: 0.3rem;border-radius: 0.3rem;top:2rem;">
            <i class="alert-close alert-close1 icon icon-close" style="right: -0.7rem;top: -0.8rem;background: #e1040d;border:none;z-index:10"></i>
            <div class="fui-list alert-header" style="-webkit-border-radius: 0.3rem;border-radius: 0.3rem;padding:0;">
                <img ng-src="{{tomedia(pagedata.goodscode)}}" class="alert-goods-img" alt="">
            </div>

        </div>
    </div>
</div>
</div>
</div>
<div id="modal_address"  class="modal fade" tabindex="-1" style="z-index:99999;display:none;">
	<div class="modal-dialog" style="width:100%;left:0;bottom:0">
	<div class="modal-bottom">
		<div ng-if="pagedata.isadd_address!=1" class="fui-content" style="background:#fff">
			<div class="fui-cell-title text-center">送至</div>
			<div ng-if="pagedata.address_list.length" class="fui-list-group address-item modal-swiper-y">
				<div class="fui-list" ng-repeat="item in pagedata.address_list" aria-hidden="true" data-dismiss="modal" ng-click="pagedata.change_address(item.id)">
					<div class="fui-list-inner">
						<div class="title red"><span class='realname'>{{item.name}}</span> <span class='mobile'>{{item.mobile}}</span></div>
						<div class="text red"><span class='address'>{{item.pcd.province}}&nbsp{{item.pcd.city}}&nbsp{{item.pcd.district}}&nbsp{{item.address}}</span></div>
					</div>
					<div class='fui-list-angle'>
                        <label class='radio-inline'>
							<input type="radio" class="fui-radio  fui-radio-danger" ng-checked="pagedata.address.id == item.id"/>
						</label>
                    </div>
				</div>
			</div>
			<div class="c" ng-click="pagedata.nowaddress={};pagedata.isadd_address=1">
				<div class="btn btn-sm btn-success-o" style="width:8rem;border-radius:1rem"><i class="icon jinyunicon icon-tianjia"></i>添加地址</div>
			</div>
			<div ng-if="!pagedata.address_list.length" class='content-empty' style="margin:0">
				<i class='icon jinyunicon icon-search'></i><br/> 您还没有地址？~ 添加一个吧 ~<br/><a ng-click="pagedata.isadd_address=1" class="btn btn-sm btn-default-o external" style="margin-top:0.5rem">添加地址</a>
			</div>
			<div ng-if="pagedata.address_list.length" class="fui-navbar"  style="padding:0.35rem 1rem">
				<a href="javascript:;" aria-hidden="true" data-dismiss="modal" class="btn btn-danger btn-banf" style="margin:0;width:100%">确定</a>
			</div>
		</div>
		<div ng-if="pagedata.isadd_address==1" class="fui-content" style="background:#fff">
			<div class='fui-cell-group'>
				<div class="fui-cell">
					<div class="fui-cell-label bold" style="width:100px;font-size:0.8rem">编辑地址</div>
					<div class='fui-cell-info r' ng-if="pagedata.openid && pagedata.isadd_address==1 && pagedata.fromh5wxapp!=1"><span class="syscolor" ng-click="pagedata.openAddress()">添加微信地址</span></div>
				</div>
                <div class='fui-cell'>
                    <div class='fui-cell-label'>收件人</div>
                    <div class='fui-cell-info'><input type="text" ng-model="pagedata.nowaddress.name" placeholder="收件人" class="fui-input"/></div>
                </div>
                <div class='fui-cell'>
                    <div class='fui-cell-label'>联系电话</div>
                    <div class='fui-cell-info'><input type="tel" ng-model="pagedata.nowaddress.mobile" placeholder="联系电话"  class="fui-input"/></div>
                </div>

                <div class="fui-cell">
					<div class="fui-cell-label ">地区</div>
					<div class="fui-cell-label" style="width:28%">
						<select ng-model="pagedata.nowaddress.pcd.province" class="form-control tpl-province">
						<option value="" selected="selected">省份</option>
						<option ng-repeat="(value,data) in pagedata.province" value="{{value}}" ng-selected="pagedata.nowaddress.pcd.province==value">{{value}}</option>
						</select>
					</div>
					<div class="fui-cell-label" style="width:28%">
						<select ng-model="pagedata.nowaddress.pcd.city" class="form-control tpl-city">
						<option value="" selected="selected">城市</option>
						<option ng-repeat="(value,data) in pagedata.province[pagedata.nowaddress.pcd.province]" value="{{value}}" ng-selected="pagedata.nowaddress.pcd.city==value">{{value}}</option>
						</select>
					</div>
					<div class="fui-cell-label" style="width:28%">
						<select ng-model="pagedata.nowaddress.pcd.district" class="form-control tpl-district">
						<option value="" selected="selected">区县</option>
						<option ng-repeat="(value,data) in pagedata.province[pagedata.nowaddress.pcd.province][pagedata.nowaddress.pcd.city]" value="{{value}}" ng-selected="pagedata.nowaddress.pcd.district==value">{{value}}</option>
						</select>
					</div>
					<div class="fui-cell-label" style="width:28%">
						<select ng-model="pagedata.nowaddress.pcd.street" class="form-control tpl-district">
						<option value="" selected="selected">街道</option>
						<option ng-repeat="value in pagedata.province[pagedata.nowaddress.pcd.province][pagedata.nowaddress.pcd.city][pagedata.nowaddress.pcd.district]" value="{{value}}" ng-selected="pagedata.nowaddress.pcd.street==value">{{value}}</option>
						</select>
					</div>
				</div>
                <div class='fui-cell'>
                    <div class='fui-cell-label'>详细地址</div>
                    <div class='fui-cell-info'><input type="text" ng-model="pagedata.nowaddress.address" placeholder='街道，楼牌号等'  class="fui-input"/></div>
                </div>
            </div>
			<div class="fui-navbar"  style="padding:0.35rem 1rem">
				<a ng-click="pagedata.add_address();" class="btn btn-danger btn-banf" style="margin:0;width:100%">确定</a>
			</div>
		</div>
	</div>
	</div>
</div>
<div ng-if="pagedata.showpicker" class="popup">
        <div class="popup-body">
            <div class="popup-bottom">
                <i class="closed icon icon-cuowu" ng-click="pagedata.showpicker=false"></i>
                <div ng-include="sys_html('goods/picker')"></div>
            </div>
        </div>
</div>
<div id="showstoreitem"  class="modal fade" tabindex="-1" style="z-index:99999;display:none;">
	<div class="modal-dialog" style="width:100%;left:0;bottom:0">
		<div class="modal-bottom">
			<div class="fui-cell-group">
				<div class="fui-cell">
					<div class="fui-cell-label" style="width:100px;font-size:0.9rem">{{pagedata.storeitem.title}}</div>
				</div>
				<div class="fui-cell noborder">
					<div class="fui-cell-label bold" style="width:80px;">地址：</div>
					<div class="fui-cell-info">{{pagedata.storeitem.pcd.province}} {{pagedata.storeitem.pcd.city}} {{pagedata.storeitem.pcd.district}} {{pagedata.storeitem.pcd.street}} {{pagedata.storeitem.address}}</div>
				</div>
				<div class="fui-cell noborder">
					<div class="fui-cell-label bold" style="width:80px;">联系人：</div>
					<div class="fui-cell-info">{{pagedata.storeitem.realname}}</div>
				</div>
				<div class="fui-cell noborder">
					<div class="fui-cell-label bold" style="width:80px;">联系电话：</div>
					<div class="fui-cell-info">{{pagedata.storeitem.mobile}}</div>
				</div>
			</div>
			<div class="fui-navbar" style="padding:0.35rem 1rem">
				<a href="javascript:;"  aria-hidden="true" data-dismiss="modal" class="btn btn-danger btn-banf" style="margin:0;width:100%">关闭</a>
			</div>
		</div>
	</div>
</div>
<div ng-if="pagedata.showshareall" class="popup">
	<div class="popup-body">
		<div class="popup-bottom" style="min-height:auto;padding-bottom:3rem">
			<div class="fui-cell-group">
				<div ng-if="pagedata.shopset.tj_hwq==1" class="fui-cell">
					<div class="fui-cell-text c">
						<div class="text bold" ng-click="pagedata.tj()" style="font-size:0.8rem"><i class="icon icon-good"></i> 推荐好物</div>
						<div class="c" style="color:#999">(分享到好物圈)</div>
					</div>
				</div>
				<div class="fui-cell">
					<div class="fui-cell-text c">
						<div class="text bold" onclick="$('#showsharecover').modal();" style="font-size:0.8rem">发送给朋友</div>
					</div>
				</div>
				<div ng-if="pagedata.goods.isposter==1" class="fui-cell">
					<div class="fui-cell-text c">
						<div class="text bold" ng-click="pagedata.showposter=true;pagedata.upposter()" style="font-size:0.8rem">生成海报</div>
					</div>
				</div>
			</div>
			<div class="fui-navbar"  style="padding:0.35rem 1rem">
				<a href="javascript:;" ng-click="pagedata.showshareall=false;pagedata.showposter=false" class="btn btn-danger btn-banf" style="margin:0;width:100%">取消</a>
			</div>
		</div>
		<div ng-if="pagedata.showposter" class="popup-center" style="width:70%;top:42%">
			<div class="fui-content c" style="height:auto;border: 1px solid #fdd8d6;border-radius:0.3rem;padding-bottom:0;background:#fff">
				<img ng-src="{{pagedata.posterimg || '../core/resource/images/nopic.jpg'}}" style="border-radius:0.3rem;width:100%;height:auto"/>
				<a class="btn btn-sm btn-danger-o external" style="line-height: 1.1rem;border-radius:1rem;margin:0.2rem;font-size:0.65rem;">长按保存图片</a>
			</div>
		</div>
	</div>
</div>
<div id="attention" ng-if="pagedata.showqrcode==1">
	<div class="attention-alert" style="width:80%;left:10%">
					<div class="attention-content" style="padding: 1.5rem 0;background:none;height:auto">
						<div class="col-jy-1" style="text-align: center;">
							<img ng-src="{{tomedia(pagedata.kefuqr) || '../core/resource/images/nopic.jpg'}}" alt=""style="width: 100%">
						</div>
						<p >长按指纹识别图中二维码</p>
					</div>
					<i class="icon icon-cuowu" ng-click="pagedata.showqrcode=0" style="font-size:1.5rem;color:#fff;position: absolute;top:105%;left:45%"></i>
	</div>
</div>
<!--弹目-->
<div ng-if="pagedata.showtanmus && pagedata.setting.no_tanmu!=1" class="video-sms-pane {{pagedata.transition?'transition':''}}">
		<div class="video-sms-text">
			<image class="video-sms-logo" ng-src="{{pagedata.tanmus[pagedata.nowmsgid].avatar}}"/>
			<span class="overflow-h"> 最新订单来自 {{pagedata.tanmus[pagedata.nowmsgid].nickname}}</span>
		</div>
</div>
<style type="text/css">
    .share-text1{text-align: center;padding:0.5rem 0.5rem 0;font-size:0.6rem;color:#666;line-height: 1rem;}
    .share-text2{text-align: center;padding:0 0.5rem 0.5rem;font-size:0.6rem;color:#666;line-height: 1rem;}
</style>
<div ng-include="sys_html('shop/_libaos')"></div>
<div ng-include="sys_html('shop/_selectstores')"></div>
<div ng-include="sys_html('common/_sales')"></div>
<script type="text/javascript">
scope.pagedata.nodata_pic='../core/resource/images/goods_nodata.jpg';
require(['bootstrap', 'hammer'], function($, Hammer){
		$('#carousel-container').carousel({interval: false});
		var mc = new Hammer($('#carousel-container').get(0));
		mc.on("panleft", function(ev) {
			$('#carousel-container').carousel('next');
		});
		mc.on("panright", function(ev) {
			$('#carousel-container').carousel('prev');
		});
		
});
scope.pagedata.tj=function(){
	var jsCheckObject={
		'appid':jssdkconfig.appId,
		'timestamp':jssdkconfig.timestamp,
		'noncestr':jssdkconfig.nonceStr,
		'signature':jssdkconfig.signature,
		'url':scope.pagedata.goods.url
		};
	if(scope.pagedata.goods.status==0){
		var status =2;
	}else if(scope.pagedata.goods.status==2){
		var status =3;
	}else{
		var status =1;
	}
	var sku={
		'sku_id':scope.pagedata.goods.id, 
		'price':(scope.pagedata.goods.price)*100,
		'original_price':(scope.pagedata.goods.originalprice)*100,
		'status':status
	}
	var productObject={
		'item_code':scope.pagedata.goods.id,
		'title':scope.pagedata.goods.title,
		'desc':scope.pagedata.goods.subtitle,
		'category_list':scope.pagedata.jy_hwqset.category_list?scope.pagedata.jy_hwqset.category_list:{"category_id": 4342,"category_name": "运动裤"}, //类目列表
		'image_list':scope.pagedata.images,
		'src_h5_path':scope.pagedata.url,
		'sku_list':sku,
		
	};
	//console.log(productObject)
	var jsCheckObject1 = encodeURIComponent(JSON.stringify(jsCheckObject))
	var productObject1 = encodeURIComponent(JSON.stringify(productObject))
	wx.openBusinessView({
	  businessType: 'friendGoodsRecommend',
	  queryString: 'jsCheck='+jsCheckObject1+'&product='+productObject1,
	  success: function (res) {
	  //{"err_msg":"errmsg","extraData":{}}
	  },
	  fail: function (res){
		scope.message(res.errMsg);
	  // alert('请检查参数配置或者公众号权限');
	  //{"err_msg":"errmsg"}
	  }
	})
}
//滚动加载
scope.pagedata.scroll_bottom=function(){
	if(scope.pagedata.showtype==0){
		if(scope.pagedata.scroll_bottomtimes){
			scope.pagedata.scroll_bottomtimes++
		}else{
			scope.pagedata.scroll_bottomtimes=1;
		}
		if(scope.pagedata.scroll_bottomtimes==1){
			scope.pagedata.showupto = 1
		}
	}
}
scope.pagedata.goDetail=function(id){
	scope.pagedata.showtype = 0;
	scope.pagedata.showpingjia=0;
	if(id=='jycontent'){
		scope.pagedata.showtype = 2;
	}
	if(id=='jytuijie'){
		scope.pagedata.showtype = 3;
	}
	if(id=='jypingjia'){
		scope.pagedata.showtype = 1;
		scope.pagedata.showpingjia=1;
		id='jyindex';
	}
	scope.$evalAsync();
	setTimeout(function(){
		var element = document.getElementById(id);
		element.scrollIntoView();
		element.scrollIntoView(false);
		element.scrollIntoView({block: "start"});
		element.scrollIntoView({behavior: "smooth", block: "start", inline: "nearest"});
	},200);
}
//减少
scope.pagedata.minus=function(){
	if(scope.pagedata.post.num <=1){
		return false;
	}
	scope.pagedata.post.num--;
	scope.$evalAsync();
}
//增加
scope.pagedata.plus=function(){
	if(parseInt(scope.pagedata.goods.usermaxbuy)>0 && parseInt(scope.pagedata.goods.order_goodscount) + parseInt(scope.pagedata.post.num)>=parseInt(scope.pagedata.goods.usermaxbuy)){
		scope.message('不能再加了，你已购买'+scope.pagedata.goods.order_goodscount+'件，超过该商品最大购买量'+scope.pagedata.goods.usermaxbuy+'！','error');
		return false;
	}
	if(parseInt(scope.pagedata.goods.maxbuy)>0 && parseInt(scope.pagedata.post.num)>=parseInt(scope.pagedata.goods.maxbuy)){
		scope.message('不能再加了，超过该商品单次购买'+scope.pagedata.goods.maxbuy+'量！','error');
		return false;
	}
	if(parseInt(scope.pagedata.post.num)>=parseInt(scope.pagedata.options.stock)){
		scope.message('不能再加了，超了库存'+scope.pagedata.options.stock+'啦！','error');
		return false;
	}
	scope.pagedata.post.num++;
	scope.$evalAsync();
}
//选择
scope.pagedata.get_optionsid=function(){
	var specid = scope.pagedata.post.specid;
		specid = specid.join('_');
	scope.post_json('jy_weishop/goods.detail/get_optionsid/',{'specid':specid},function(res){
			console.log(specid);
			scope.pagedata.post.optionsid=res.options.id;
			scope.pagedata.options=res.options;
			scope.pagedata.goods.price=res.options.price;
			scope.pagedata.goods.image=res.options.thumb?res.options.thumb:scope.pagedata.goods.image;
			scope.pagedata.goods.originalprice=res.options.productprice;
			scope.pagedata.selespename=res.selespename;
			scope.$evalAsync();
	});
}
scope.pagedata.add_address=function(){
	scope.pagedata.nowaddress.res=1
	scope.pagedata.isadd_address=0;
	scope.post_json('core/member.address/post/',scope.pagedata.nowaddress,function(res){
			scope.pagedata.post.addressid =res;
			scope.pagedata.address=scope.pagedata.nowaddress;
			scope.pagedata.address.id=res;
			scope.pagedata.address_list = scope.pagedata.address_list.concat(scope.pagedata.address)
			$('#modal_address').modal('hide');
			scope.$evalAsync();
	});
}
//选择地址
scope.pagedata.change_address=function(id){
	scope.post_json('jy_weishop/goods.detail/change_address/',{'addressid':id},function(res){
			scope.pagedata.post.addressid=res.address.id;
			scope.pagedata.address=res.address;
			scope.$evalAsync();
	});
}
//获取关注
scope.pagedata.setlike=function(){
	scope.post_json('jy_weishop/goods.detail/like/',{},function(res){
		scope.message(res);
	});
}
//加入清单
scope.pagedata.addqingdan=function(){
	scope.post_json('jy_weishop/sale.qingdan/add/',{'goodsid':scope.pagedata.goods.id},function(res){
		scope.message(res);
	});
}
//if(scope.pagedata.goods.type==3 || (scope.pagedata.goods.type==0 && scope.pagedata.goods.isverify==1)){
	scope.pagedata.getstores=function(lat_lng){
		var id=scope.pagedata.goods.id;
		scope.post_json('/get_data/getstores/',{'lat_lng':lat_lng,'id':id},function(res){
				scope.pagedata.stores =res.stores
				scope.pagedata.stores_count =res.stores_count
				if(!scope.pagedata.post.storeid){
					scope.pagedata.post.storeid = res.stores[0]?res.stores[0].id:0;
				}
				scope.$evalAsync();
		});
	}
	// 百度地图API功能
	if(!scope.pagedata.lat_lng && !scope.main.lat_lng){
		scope.pagedata.setting=scope.pagedata.setting?scope.pagedata.setting:{}
		window.scope.location(function(re){
			scope.main.lat_lng=re.lat_lng;
			scope.main.pcd=re.addressComponents;
			scope.pagedata.getstores(re.lat_lng);
		},scope.pagedata.setting.no_location);
	}else{
		scope.pagedata.getstores(scope.pagedata.lat_lng);
	}
//}
scope.pagedata.showstoreitem=function(){
	$('#showstoreitem').modal();
}
scope.pagedata.check_buy=function(){
	var goodsid=scope.pagedata.post.goodsid
	var num=scope.pagedata.post.num
	var optionsid=scope.pagedata.post.optionsid
	var addressid=scope.pagedata.post.addressid
	var storeid=scope.pagedata.post.storeid
	scope.get('jy_weishop/goods.detail/check_buy/isresurl=1&goodsid='+goodsid+'&num='+num+'&optionsid='+optionsid+'&addressid='+addressid+'&storeid='+storeid,function(resurl){
		scope.access_json(resurl);
	});
}
</script>
<script>
scope.pagedata.issocketmsg=false;
scope.pagedata.tanmuspage=0;
scope.pagedata.isa2=true;
scope.pagedata.isno_coupontop=1;
scope.pagedata.gettanmus=function() {
	if(!scope.pagedata.issocketmsg){
			scope.pagedata.nowmsgid=0;
			scope.get('jy_weishop/get_data/gettanmus/page='+scope.pagedata.tanmuspage,function(res){
						//console.log(res);
						scope.pagedata.tanmus=res.list
						if(scope.pagedata.tanmus.length>0){
							scope.pagedata.tanmuspage++;
							scope.pagedata.up_oldtanmu();
						}
			});
	}
}
//刚进入时；如果没有新订单消息，就弹储备订单消息
if(scope.pagedata.setting.no_tanmu!=1){
		setTimeout(function(){
			scope.pagedata.gettanmus();
		},2000);
}
scope.pagedata.up_oldtanmu=function() {
		if(scope.page.action=='goods.detail'){
			var i=scope.pagedata.nowmsgid;
			if(i<scope.pagedata.tanmus.length){
				set_tanmu(scope.pagedata.tanmus[i].nickname,scope.pagedata.tanmus[i].avatar,scope.pagedata.tanmus[i].time);
			}else{
				scope.pagedata.gettanmus();
			}
		}else{
			return false;
		}
}
function set_tanmu(nickname,avatar,time) {
		scope.pagedata.nowmsgid++
		scope.pagedata.showtanmus=true
		scope.$evalAsync(scope.pagedata.showtanmus);
		setTimeout(function(){
			scope.pagedata.transition=true
			scope.$evalAsync(scope.pagedata.transition);	
		},300);
		setTimeout(function(){
			scope.pagedata.showtanmus=false
			scope.pagedata.transition=false
			scope.$evalAsync(scope.pagedata.showtanmus);	
		},2000);
		setTimeout(function(){
			//等待5秒，如果没有新的订单消息，就弹储备订单消息
			scope.pagedata.issocketmsg=scope.pagedata.issocketmsg?scope.pagedata.issocketmsg:false;
			if(!scope.pagedata.issocketmsg && scope.page.action=='index'){
				scope.pagedata.up_oldtanmu();
			}
		},4000);
}
scope.tool.get_list('jy_weishop/goods.detail/getcomments/goodsid='+scope.pagedata.goods.id,true);
if(scope.main.isapp!=1){
setTimeout(function(){
	scope.pagedata.showcontent=1;
	var jypingjia = $("#jypingjia").offset().top;
	var jycontent = $("#jycontent").offset().top;
	scope.pagedata.jytuijie = $("#jytuijie").offset().top;
	console.log(jypingjia);console.log(jycontent);console.log(scope.pagedata.jytuijie);
	$(window).unbind('scroll');
	$(window).scroll(function(){
		if(scope.page.action!='goods.detail'){
			return false;
		}
		var scrollTop =parseInt($(this).scrollTop());//滚动高度
		scrollTop +=60;
		//console.log(scrollTop);
		if(scope.pagedata.showpingjia==1){
			scope.pagedata.scroll_bottom=function(){
				scope.tool.get_list('jy_weishop/goods.detail/getcomments/goodsid='+scope.pagedata.goods.id+'&type='+scope.pagedata.comments_type);
			}
			return false;
		}
		if(scope.pagedata.showcontent!=1){
			scope.pagedata.scroll_bottom=function(){
				if(scope.pagedata.showcontent!=1){
					scope.pagedata.showcontent=1
					scope.$evalAsync();
				}
			}
		}
		setTimeout(function(){
			if(scope.pagedata.showcontent!=1 && (scrollTop>200 || jycontent<480)){
				scope.pagedata.showcontent=1
				scope.$evalAsync();
			}
			if(jypingjia>scrollTop && scope.pagedata.showtype!=0){
				console.log('index');
				scope.pagedata.showtype=0
				scope.$evalAsync();
			}else if(jypingjia<=scrollTop && jycontent>scrollTop && scope.pagedata.showtype!=1){
				console.log('jypingjia');
				scope.pagedata.showtype=1
				scope.pagedata.showcontent=1
				scope.$evalAsync();
			}else if(jycontent<=scrollTop && scope.pagedata.jytuijie>scrollTop && scope.pagedata.showtype!=2){
				console.log('jycontent');
				scope.pagedata.showtype=2
				scope.pagedata.jytuijie = $("#jytuijie").offset().top;
				scope.$evalAsync();
			}else if(scope.pagedata.jytuijie<=scrollTop && scope.pagedata.showtype!=3){
				console.log('jytuijie');
				scope.pagedata.showtype=3
				scope.$evalAsync();
			}
		},500);
	});
},2000);
}else{
	scope.pagedata.showcontent=1;
}
scope.pagedata.selectstores=function(item){
	console.log('选择门店'+item.id);
	scope.pagedata.post.storeid=item.id;
	scope.get('jy_weishop/get_data/get_upgoods/storeid='+item.id+'&id='+scope.pagedata.goods.id,function(res){
		scope.pagedata.goods.canbuy=res.canbuy;
		scope.pagedata.selectstore=item;
		scope.$evalAsync();
	});
}
scope.pagedata.itemtokefu=function(){
	if(scope.pagedata.shopset.h5appkf==1 && window.config.fromh5wxapp==1 && window.config.container!='ttapp' && window.config.container!='baiduapp'){
		//H5小程序环境下
		var logo=scope.tomedia(scope.pagedata.account.logo);
		var title=scope.pagedata.account.title
		wx.miniProgram.navigateTo({
			url: '/pages/kefu/index?logo='+logo+'&title='+title
		})
	}else{
		if(scope.pagedata.goods.merchid!=0 && scope.pagedata.goods.merch.showkefu==1){
			scope.access_json('jy_kefu/home//pn=jy_merch&pid='+scope.pagedata.goods.merchid);
		}else if(scope.pagedata.setting.nokefu2!=1 && scope.pagedata.goods.merchid==0 && (!scope.pagedata.shopset.kefutype_h5 || scope.pagedata.shopset.kefutype_h5==0)){
			scope.access_json(scope.pagedata.shopset.kflink);
		}else if(scope.pagedata.setting.nokefu2!=1 && scope.pagedata.goods.merchid==0 && scope.pagedata.shopset.kefutype_h5==1){
			scope.pagedata.kefuqr=scope.pagedata.shopset.kf_accountimg;
			scope.pagedata.showqrcode=1;
		}else if(scope.pagedata.setting.nokefu2!=1 && scope.pagedata.goods.merchid==0 && scope.pagedata.shopset.kefutype_h5==2){
			scope.access_json(scope.pagedata.shopset.appkflink)
		}else if(scope.pagedata.setting.nokefu2!=1 && scope.pagedata.goods.merchid==0 && scope.pagedata.shopset.kefutype_h5==3){
			scope.access_json(scope.pagedata.shopset.workerh5url);
		}else if(scope.pagedata.setting.nokefu2!=1 && scope.pagedata.goods.merchid==0 && scope.pagedata.shopset.kefutype_h5==4){
			scope.pagedata.kefuqr=scope.pagedata.shopset.guwenkfewm;
			scope.pagedata.showqrcode=1;
		}else if(scope.pagedata.setting.nokefu2!=1 && scope.pagedata.goods.merchid==0 && scope.pagedata.shopset.kefutype_h5==5){
			window.location.href = "tel:" +scope.pagedata.shopset.phone;
		}
		scope.$evalAsync();
	}
}
scope.pagedata.pickeraddtocart=function(){
    scope.post_json('jy_weishop/goods.detail/addtocart/isres=1',scope.pagedata.post,function (res){
        scope.message('成功加入购物车！');
        scope.pagedata.cartnums=res.cartnums;
        scope.pagedata.cartCount=res.cartnums;
        if(scope.main.menus && scope.main.menus.length>0){
            for(var i=0;i<scope.main.menus.length;i++){
                var action=scope.main.menus[i].action
                if(action.indexOf("jy_weishop/member.cart") != -1){
                    var key=i;
                    scope.main.menus[key].nums=scope.pagedata.cartnums
                }
            }
        }
        scope.pagedata.showpicker=false
        scope.$evalAsync();
    })
}
scope.pagedata.upposter=function(){
	scope.get('jy_weishop/goods.detail/upposter/goodsid='+scope.pagedata.goods.id,function(res){
		console.log(res)
		scope.pagedata.posterimg=res.posterimg;
		scope.$evalAsync();
	});
}
scope.pagedata.getprovince=function(){
	scope.get('jy_weishop/get_data/getprovince/',function(res){
		scope.pagedata.province=res.province;
		scope.$evalAsync();
	});
}
if(scope.pagedata.goods.type==0 && scope.pagedata.shopset.no_goodssongda!=1){
	scope.pagedata.getprovince();
}
if(scope.main.uplookgoodsurl){
	scope.pagedata.nowmsgid=0;
	scope.main.uplooktime=scope.main.uplooktime?scope.main.uplooktime:10;
	var time=scope.main.uplooktime*1000
	setTimeout(function(){
		console.log('uplookgoodsurl');
		if(scope.main.uplookgoodsurl && scope.page.plugin=='jy_weishop' && scope.page.action=='goods.detail'){
			scope.get(scope.main.uplookgoodsurl,function(res){
				scope.message(res);
			});
		}
		scope.main.uplookgoodsurl=false
	},time);
}
scope.pagedata.openAddress=function (){
	wx.openAddress({
		  success: function (res) {
			scope.pagedata.nowaddress={}
			scope.pagedata.nowaddress.name = res.userName; // 收货人姓名
			scope.pagedata.nowaddress.pcd={}
			scope.pagedata.nowaddress.pcd.province = res.provinceName; // 国标收货地址第一级地址（省）
			scope.pagedata.nowaddress.pcd.city = res.cityName; // 国标收货地址第二级地址（市）
			scope.pagedata.nowaddress.pcd.district = res.countryName; // 国标收货地址第三级地址（国家）
			scope.pagedata.nowaddress.address = res.detailInfo; // 详细收货地址信息
			scope.pagedata.nowaddress.mobile = res.telNumber; // 收货人手机号码
			scope.$evalAsync();
		  },
		  fail: function (res) {
			console.log('fail');console.log(res)
		  }
	});
}
</script>